﻿/**
*增加佣金比例
*/
Chenxin.UI.AddScaleForm = Chenxin.extend(Chenxin.UI.FormCommon, {
    actionUrl: '/service/logic/CommissionScale.ashx',
    id: 'AddScale',
    renderTo: 'divAddScale',
    winCls: '',
    jqmWidth: 560,
    title: '添加佣金比例',
    op: 'addscale',
    autoHide:false,
    defBBtn: true,
    createForm: function() {
        return Chenxin.FormCommon.AddScaleForm(this.id);
    },
    initEvent: function() {
        var _this = this;
        var date = new Date();
        $("#stime").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        }).val(date.getFullYear() + '-' + (date.getMonth() + 1));

        $("#etime").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        }).val(date.getFullYear() + '-' + (date.getMonth() + 1));
    },
    initFormValidator: function() {
        //起始日期
        $("#stime").formValidator({
            validatorgroup: this.id,
            onshow: "请选择起始日期！",
            onfocus: "请选择起始日期！",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "不能为空！"
            },
            onerror: "不能为空！"
        });

        //结束日期
        $("#etime").formValidator({
            validatorgroup: this.id,
            onshow: "请选择结束日期！",
            onfocus: "请选择结束日期！",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "不能为空！"
            },
            onerror: "不能为空！"
        });

        //佣金比例
        $("#RatioTemp").formValidator({
            validatorgroup: this.id,
            onshow: "请佣金比例！",
            onfocus: "请佣金比例！",
            oncorrect: " "
        }).inputValidator({
            min: 1,
            empty: {
                leftempty: false,
                rightempty: false,
                emptyerror: "不能为空！"
            },
            onerror: "不能为空！"
        }).functionValidator({ //数字验证
            fun: function(val, elem) {
                return val.isNum();
            },
            onerror: "请输入数字"
        });
    },
    saveSucc: function() {
        this.reloadGrid();
    },
    initComponent: function() {
        Chenxin.UI.AddScaleForm.superclass.initComponent.call(this);
    }
});

Chenxin.FormCommon.AddScaleForm = function(formID) {
return '<table style="width:100%;margin:5px 0px;"><tbody><tr style="line-height: 26px;"><th style="width:80px;text-align:right;">起始日期：</th><td><input style="width:120px;" name="stime" class="inputbox_n fl" id="stime" type="text"  /><div id="stimeTip" style="float: left; margin-left: 5px; width: 121px; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td><tr style="line-height: 26px;"><th style="text-align:right;">结束日期：</th><td><input style="width:120px;" name="etime" class="inputbox_n fl" type="text" id="etime" /><div id="etimeTip" style="float: left; margin-left: 5px; width: 121px; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td></tr><tr style="line-height: 26px;"><th style="text-align:right;">最小金额：</th><td><input style="width:120px;" name="AchievementsMin" id="moneymin" class="inputbox_n fl" type="text" /></td></tr><tr><th style="text-align:right;">最大金额：</th><td><input style="width:120px;" name="AchievementsMax" id="moneymax" class="inputbox_n fl" type="text" /></td></tr><tr><th style="text-align:right;">佣金比例：</th><td><input style="width:120px;" name="Ratio" id="RatioTemp" class="inputbox_n fl" type="text" /><div id="RatioTempTip" style="float: left; margin-left: 5px; width: 121px; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td></tr><tr><th style="text-align:right;">抵扣金额：</th><td><input style="width:120px;" name="Deduct" id="Deduct" class="inputbox_n fl" type="text" /></td></tr></tbody></table>';
};